package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WebUserCardRechargeTransition;
import com.ruoyi.system.service.IWebUserCardRechargeTransitionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 转次数卡记录Controller
 * 
 * @author wsliupan@126.com
 * @date 2021-06-28
 */
@Controller
@RequestMapping("/system/UserCardRechargeTransition")
public class WebUserCardRechargeTransitionController extends BaseController
{
    private String prefix = "system/UserCardRechargeTransition";

    @Autowired
    private IWebUserCardRechargeTransitionService webUserCardRechargeTransitionService;

    @RequiresPermissions("system:UserCardRechargeTransition:view")
    @GetMapping()
    public String UserCardRechargeTransition()
    {
        return prefix + "/UserCardRechargeTransition";
    }

    /**
     * 查询转次数卡记录列表
     */
    @RequiresPermissions("system:UserCardRechargeTransition:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WebUserCardRechargeTransition webUserCardRechargeTransition)
    {
        startPage();
        List<WebUserCardRechargeTransition> list = webUserCardRechargeTransitionService.selectWebUserCardRechargeTransitionList(webUserCardRechargeTransition);
        return getDataTable(list);
    }

    /**
     * 导出转次数卡记录列表
     */
    @RequiresPermissions("system:UserCardRechargeTransition:export")
    @Log(title = "转次数卡记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WebUserCardRechargeTransition webUserCardRechargeTransition)
    {
        List<WebUserCardRechargeTransition> list = webUserCardRechargeTransitionService.selectWebUserCardRechargeTransitionList(webUserCardRechargeTransition);
        ExcelUtil<WebUserCardRechargeTransition> util = new ExcelUtil<WebUserCardRechargeTransition>(WebUserCardRechargeTransition.class);
        return util.exportExcel(list, "转次数卡记录数据");
    }

    /**
     * 新增转次数卡记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存转次数卡记录
     */
    @RequiresPermissions("system:UserCardRechargeTransition:add")
    @Log(title = "转次数卡记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WebUserCardRechargeTransition webUserCardRechargeTransition)
    {
        return toAjax(webUserCardRechargeTransitionService.insertWebUserCardRechargeTransition(webUserCardRechargeTransition));
    }

    /**
     * 修改转次数卡记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WebUserCardRechargeTransition webUserCardRechargeTransition = null;
        if(id == null || id ==  -1){
            webUserCardRechargeTransition = new WebUserCardRechargeTransition();
        }else{
            webUserCardRechargeTransition = webUserCardRechargeTransitionService.getById(id);
        }
        mmap.put("webUserCardRechargeTransition", webUserCardRechargeTransition);
        return prefix + "/edit";
    }

    /**
     * 修改保存转次数卡记录
     */
    @RequiresPermissions("system:UserCardRechargeTransition:edit")
    @Log(title = "转次数卡记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WebUserCardRechargeTransition webUserCardRechargeTransition)
    {
        return toAjax(webUserCardRechargeTransitionService.updateWebUserCardRechargeTransition(webUserCardRechargeTransition));
    }

    /**
     * 删除转次数卡记录
     */
    @RequiresPermissions("system:UserCardRechargeTransition:remove")
    @Log(title = "转次数卡记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(webUserCardRechargeTransitionService.deleteWebUserCardRechargeTransitionByIds(ids));
    }
}
